package com.faceCaptor.main;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.wb.swt.SWTResourceManager;

public class ContactDialog extends Dialog {

    private String  qrCodePath = "images/qrCode.jpg";
    public static void main(String[] args) {
        ContactDialog messageDialog = new ContactDialog(null);
        messageDialog.open();
    }
    protected ContactDialog(Shell parentShell) {
        super(parentShell);
    }

    @Override
    protected void configureShell(Shell newShell) {
        super.configureShell(newShell);
        newShell.setText("联系我们");
        Font font1 = new Font(newShell.getDisplay(), "宋体", 12, SWT.NONE);
        newShell.setFont(font1);
    }

    @Override
    protected Control createDialogArea(Composite parent) {
        Composite container = (Composite) super.createDialogArea(parent);

        GridLayout layout = new GridLayout(1,true);
        layout.marginLeft=20;
        layout.marginRight=20;
        layout.marginTop=20;
        layout.marginBottom=20;
        layout.numColumns = 1;
        container.setLayout(layout);
        container.setLayoutData(new GridData(GridData.FILL_BOTH));


        CLabel label1 = new CLabel(container,SWT.NONE);
        GridData data = new GridData(SWT.CENTER,SWT.CENTER,true,true);
        label1.setLayoutData(data);
        label1.setText("人脸识别AI门店");

        CLabel label = new CLabel(container,SWT.None);
        data = new GridData(SWT.CENTER,SWT.CENTER,true,true);

        label.setLayoutData(data);
        label.setImage(SWTResourceManager.getImage("images/qrCode.jpg"));

//        Font sysFont = parent.getDisplay().getSystemFont();
//        Font font1 = new Font(parent.getDisplay(),sysFont.getFontData()[0].getName(), 10, SWT.NONE);
//        CLabel label1 = new CLabel(container,SWT.None);
//        label1.setText("公司:");
//        label1.setFont(font1);
//
//        CLabel label2=new CLabel(container,SWT.None);
//        label2.setText("联系人:");
//        label2.setFont(font1);
//
//        CLabel label3=new CLabel(container,SWT.None);
//        label3.setText("电话:");
//        label3.setFont(font1);


        Color color = Display.getCurrent().getSystemColor(SWT.BACKGROUND);
        container.setForeground(color);
        return container;
    }

    @Override
    protected Point getInitialSize() {
        return new Point(500, 500);
    }

    @Override
    protected Point getInitialLocation(Point initialSize){
        Point location = new Point(this.getParentShell().getLocation().x
                + 100, this.getParentShell().getLocation().y
                + 100);
        return location;
//        return new Point(100,100);

    }

    @Override
    protected void createButtonsForButtonBar(Composite parent) {
        Button button=createButton(parent, IDialogConstants.OK_ID, "确定", true);
        GridData gridData = (GridData) parent.getLayoutData();
        gridData.horizontalAlignment = SWT.CENTER;

//        button.setAlignment(SWT.HORIZONTAL);
//        createButton(parent, IDialogConstants.CANCEL_ID, "关闭", false);
    }
}
